/**
 * 代号:金花 
 * 文件名：WeatherData.java
 * 创建人：jh
 * 日期：2018年7月31日
 * 修改人：
 * 描述：
 */
package cc.pattern.observation.weather;

import cc.pattern.observation.inter.Observer;
import cc.pattern.observation.inter.Subject;

import java.util.ArrayList;
import java.util.List;

/**
 * 用途：业务模块名称
 */
public class WeatherData2 implements Subject {

	private List<Observer> obs = new ArrayList<>();
	private String temperature;
	private String humidity;
	private String pressure;

	public String getTemperature() {
		return temperature;
	}

	public String getHumidity() {
		return humidity;
	}

	public String getPressure() {
		return pressure;
	}

	public void setTemperature(String temperature) {
		this.temperature = temperature;
	}

	public void setHumidity(String humidity) {
		this.humidity = humidity;
	}

	public void setPressure(String pressure) {
		this.pressure = pressure;
	}

	public void measurementsChanged() {
		notifyObservers(); // 调用
	}

	@Override
	public void notifyObservers() {
		// TODO Auto-generated method stub
		for (Observer observer : obs) {
			observer.update(this);
		}
	}

	@Override
	public void registerObserver(Observer o) {
		// TODO Auto-generated method stub
		obs.add(o);
	}

	@Override
	public void removeObserver(Observer o) {
		// TODO Auto-generated method stub
		obs.remove(o);
	}

}
